package cn.tedu.charging.common.pojo;

import lombok.*;
import lombok.experimental.FieldDefaults;

/**
 * 统一返回结果
 */
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class JsonResult<T> {
    // 状态码
    Integer code;
    // 提示信息
    String message;
    // 接口的出参，具体的数据   泛型
    T data;

    public static JsonResult ok(Object data, String msg) {
        JsonResult result = new JsonResult();
        result.setCode(2000);
        result.setData(data);
        result.setMessage(msg);
        return result;
    }
    public static JsonResult ok(Object data) {
        return ok(data, "操作成功");
    }
}
